<template>
  <div class="goodsItem" @click='itemClick'>
    <img v-lazy='goodsItem.image||goodsItem.show.img' alt="" @load='imageLoad'>
    <div class="detail">
      <p>{{goodsItem.title}}</p>
      <span class="price">¥{{goodsItem.price}}</span>
      <span class="collect">{{goodsItem.cfav}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: '',
    props: {
      goodsItem: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    data() {
      return {

      }
    },
    methods: {
      imageLoad() {
        this.$bus.$emit('itemImageLoad')
      },
      itemClick() {
        if (this.goodsItem.iid) {
          this.$router.push('/detail/' + this.goodsItem.iid)
        }
        // else {
        //   this.$router.push('/detail/' + this.goodsItem.item_id)
        // }
      }
    },
    components: {

    }
  }
</script>

<style scoped>
  .goodsItem {
    width: 48%;
    padding-bottom: 15px;
  }

  .goodsItem img {
    width: 100%;
    border-radius: 5px;
  }

  .detail {
    font-size: 12px;
    text-align: center;
    padding-top: 5px;
  }

  .detail p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .price {
    color: deeppink;
  }

  .collect {
    position: relative;
    padding-left: 30px;
  }

  .collect::before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    left: 17px;
    top: 0;
    background-image: url("~assets/img/detail/detail_bottom.png");
    background-position: 0 1px;
    background-size: 12px;
  }
</style>